using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace oms.Shared.Data;

/// <summary>
/// 泛型枚举转换器，用于将枚举值存储为字符串（忽略大小写）
/// </summary>
/// <typeparam name="TEnum">枚举类型</typeparam>
public class GenericEnumConverter<TEnum>() : ValueConverter<TEnum, string>(v => v.ToString().ToLower(),
    v => Enum.Parse<TEnum>(v,true))
    where TEnum : struct, Enum;